#include "gemm.hpp"

GEMMTester::GEMMTester(size_t n, size_t k, size_t m) {
  _input_matrix1 = Matrix<int>(n, k);
  _input_matrix2 = Matrix<int>(k, m);
}

void GEMMTester::DataGenerate() {
  std::random_device rd;
  std::mt19937 gen(rd());
  std::uniform_int_distribution<int> dis(0, 1);
  size_t row = _input_matrix1.Row();
  size_t col = _input_matrix1.Col();
  for (size_t i = 0; i < row; ++i) {
    for (size_t j = 0; j < col; ++j) {
      _input_matrix1[i][j] = dis(gen);
    }
  }
  row = _input_matrix2.Row();
  col = _input_matrix2.Col();
  for (size_t i = 0; i < row; ++i) {
    for (size_t j = 0; j < col; ++j) {
      _input_matrix2[i][j] = dis(gen);
    }
  }
}

bool GEMMTester::CheckResult() {
  if (_baseline_result.Row() != _impl_result.Row() ||
      _baseline_result.Col() != _impl_result.Col()) {
    return false;
  }
  size_t row = _baseline_result.Row();
  size_t col = _baseline_result.Col();
  bool ret = true;
  for (size_t i = 0; i < row; ++i) {
    for (size_t j = 0; j < col; ++j) {
      if (_baseline_result[i][j] != _impl_result[i][j]) {
        ret = false;
        break;
      }
    }
  }
  return ret;
}
